package com.tree.backend.controller;

import com.tree.backend.common.Result;
import com.tree.backend.entity.vo.dashboard.*;
import com.tree.backend.service.IDashboardService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Dashboard控制器
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/dashboard")
public class DashboardController {

    private final IDashboardService dashboardService;

    /**
     * 获取首页统计数据
     *
     * @return 统计数据
     */
    @GetMapping("/stats")
    public Result<DashboardStatsVO> getDashboardStats() {
        DashboardStatsVO stats = dashboardService.getDashboardStats();
        return Result.success(stats);
    }

    /**
     * 获取部门成本分布数据
     *
     * @return 部门成本分布数据
     */
    @GetMapping("/department-cost")
    public Result<DepartmentCostDistributionVO> getDepartmentCostDistribution() {
        DepartmentCostDistributionVO distribution = dashboardService.getDepartmentCostDistribution();
        return Result.success(distribution);
    }

    /**
     * 获取成本项目分析数据
     *
     * @return 成本项目分析数据
     */
    @GetMapping("/cost-item-analysis")
    public Result<CostItemAnalysisVO> getCostItemAnalysis() {
        CostItemAnalysisVO analysis = dashboardService.getCostItemAnalysis();
        return Result.success(analysis);
    }

    /**
     * 获取成本趋势分析数据
     *
     * @return 成本趋势分析数据
     */
    @GetMapping("/cost-trend")
    public Result<CostTrendAnalysisVO> getCostTrendAnalysis() {
        CostTrendAnalysisVO trend = dashboardService.getCostTrendAnalysis();
        return Result.success(trend);
    }

    /**
     * 获取月度支出对比数据
     *
     * @return 月度支出对比数据
     */
    @GetMapping("/monthly-expense-comparison")
    public Result<MonthlyExpenseComparisonVO> getMonthlyExpenseComparison() {
        MonthlyExpenseComparisonVO comparison = dashboardService.getMonthlyExpenseComparison();
        return Result.success(comparison);
    }
}